package 网络编程;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UdpClient {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket=new DatagramSocket();
        //创建IP地址
        InetAddress inetAddress=InetAddress.getByName("127.0.0.1");
        //创建端口号
        int port=8899;
        //发送内容
        String str="天门市第一人民医院";
        DatagramPacket packet=new DatagramPacket(str.getBytes(),0,str.getBytes().length,inetAddress,port);
        //发送数据
        socket.send(packet);
        socket.close();
    }
}
